package core

import "strings"

type HeadItem struct {
	FiledName string
	Typ       string
	CellVal   string
	Ix        int
}
type HeadInfo struct {
	Items       []*HeadItem
	ItemsByName map[string]*HeadItem
}

func (info *HeadInfo) AddItem(
	ix int,
	typ string,
	fieldName string,
	cellVal string) {

	item := new(HeadItem)
	item.Ix = ix
	info.Items = append(info.Items, item)
	item.FiledName = strings.TrimSpace(fieldName)
	item.CellVal = cellVal
	item.Typ = strings.ToLower(typ)
	item.FiledName = fieldName
	// byType
	info.ItemsByName[item.Typ] = item
}

func (info *HeadInfo) GetItemByType(typ string) *HeadItem {
	return info.ItemsByName[typ]
}
